package top.ezzz.search.model;


import cn.hutool.json.JSONObject;

/**
 * @author noear
 * @since 1.0.2
 */
public class EsSetting {

    private final JSONObject obj;

    public EsSetting(JSONObject obj) {
        this.obj = obj;
    }


    public EsSetting set(String name, Object value) {
        if (obj.get("settings") == null) {
            obj.set("settings", new JSONObject());
        }
        obj.getJSONObject("settings").set(name, value);
        return this;
    }

    /**
     * 设置副本数
     */
    public EsSetting setNumberOfReplicas(int value) {
        return set("index.number_of_replicas", value);
    }

    /**
     * 设置刷新时间
     *
     * @param value 例：5000,"5s"
     */
    public EsSetting setRefreshInterval(Object value) {
        return set("index.refresh_interval", value);
    }
}
